<?php

require_once('include_dao.php');

$urlVariables = explode("/",$_SERVER['REQUEST_URI']);
$count = count($urlVariables);


$categoryId= $urlVariables[$count-3];
$target= $urlVariables[$count-2];
if(!is_numeric($target)){

include "error.php";
exit();
}
try{

if($target==0){

    include "list.php";
    
}else{

    $row = DAOFactory::getQuestionmasterDAO()->load($target);
    
	$category = DAOFactory::getCategorymasterDAO()->load($row->categoryMasterId);	
if($row->questionType>0){
   
    $initialquestion = DAOFactory::getQuestionmasterDAO()->load($row->firstLink);
    $titlequestion = DAOFactory::getQuestionmasterDAO()->load($initialquestion->parentQuestionId);
}
else{
	$titlequestion = DAOFactory::getQuestionmasterDAO()->load($row->parentQuestionId);
}
   
    if($row->questionType ==2){
        $answer = $row;
        include "answer.php";

    }else{
        $question = $row;
        include "question.php";

    }

}

}catch(Exception $e){

include "error.php";

}
?>
